<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %> 
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                com.scalar.chiptrack.operations.LotQuantity,
                com.scalar.chiptrack.operations.Inventory,
                com.scalar.chiptrack.operations.LotNumberQtyAndDateOut,
                com.scalar.chiptrack.operations.ReservedQuantity,
                com.scalar.chiptrack.sales.dao.SalesDAO,
                com.scalar.chiptrack.sales.dao.SalesOrderDAO,
                com.scalar.chiptrack.sales.LineItem,
                com.scalar.chiptrack.utils.StringUtils,
                com.scalar.chiptrack.users.Functionality,
                com.scalar.chiptrack.users.User,
                com.scalar.chiptrack.commons.SessionKeys,
                com.scalar.chiptrack.commons.Constants,
                java.util.ArrayList,
                java.util.Iterator,
                java.util.Date,
                java.util.Calendar,
                java.util.GregorianCalendar,
                java.util.HashMap"%>

<HTML><HEAD><TITLE>ScalarSoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type='text/css' rel='stylesheet'>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>


<script language="JavaScript1.2">
<!--


//Added by Sarada on 30th Oct 2003 to do validations for scheduleDate
var errors = "";

// added by Prabhanjan on 16th November 2003.
// This is used in closeWindow() function and indicates whether schedule date is saved from this page.
var isScheduleDateSaved = 0;
//Added by veeru on 31st March 2004
var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;
    newWindow1 = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow1.moveTo(550,180);
    newWindow1.focus();
}

function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}

function dateValidation()
{
	errors = "";
	var dateValue = "";
    var tempDate = document.lineItemForm["scheduleDate"];
	//alert(tempDate.value);

	if( typeof tempDate.length == 'undefined' )
    {
	    if( chkScheduleRevisedDate(tempDate.value.trim(),"Schedule Date","Y") == false)
		{
			errors = errMsg;
			tempDate.select();
			tempDate.focus();
		}
	}
	else
	{

		for(var i=0; i< tempDate.length; i++)
		{
			if( chkScheduleRevisedDate(tempDate[i].value.trim(),"Schedule Date","Y") == false)
			{
				errors = errMsg;
				tempDate[i].select();
				tempDate[i].focus();
				break ;
			}
		}//for

    } //else

    if(errors != '')
		return false;
    else
        return true;
}


	function submitForm(actionValue)
	{
      //Added by Sarada on 30th Oct 2003 to do validations for scheduleDate
		var errors1 = '';

		if( dateValidation() == false )
		{
            errors1 = errors;
        }

		if(errors1 != '')
        {
            var pa=document.getElementById("errors");
            pa.innerHTML = errors1;
			return;
        }

		//Sarada's code ends here
            //Added by Rohan on August 27th 2003
            //To check if the parent form is approver order form and if so setting the schedule date before submitting
		if(window.opener.document.approverOrderForm!=null)
		{
		// Added by Sarada on 29th Oct 2003 to pass systemSuggDate value from this Order Scheduling to Pending Orders screen
        // commented by Prabhanjan on 22 November 2003
        /*
          if(document.lineItemForm.scheduleDate != null)
          {
            if(document.lineItemForm.scheduleDate.value.length == 0 || document.lineItemForm.scheduleDate.value == ' ')
			{
			   if(document.lineItemForm.systemSuggDate.value != ' ' && document.lineItemForm.systemSuggDate.value.length != 0)
					document.lineItemForm.scheduleDate.value = document.lineItemForm.systemSuggDate.value
			}
           }
         */
			 //alert(document.lineItemForm.scheduleDate.value);
		   	window.opener.setScheduleDate(document.lineItemForm.lineItemId.value,document.lineItemForm.scheduleDate.value);
			}
            //End of additions by Rohan on August 27th 2003
            document.lineItemForm.action = '<%=chipTracContext%>/scheduling.do?action=' + actionValue;
            document.lineItemForm.submit();
        }

	  var holdCount = 0;
	  var holdWeeks = new Array(13);

      // added by prabhanjan on 27th October 2003
      // To make the arrays of lot details and sales orders details separate
      // as using the single array for both gives rise to script errors, when both details for a particular week present.
      // holdWeeks array hold the Lot Details while the newly added holdOrderWeeks array hold the Sales Order Details
      var holdOrderWeeks = new Array(13);

	  var division = "lotDivision";
          var division1 = "orderDivision";
	  var divColor = "#dadcba";
	  var styleSheet = "NArial";
	  var bgColor = "#993333";
	  var fontColor = "BArial";
	  var body = "";

	  function Week(name){
		this.count = 0;
		this.name = name;
		this.lotInfoArray = new Array();
	  }

	  Week.prototype.addLotDetails = function(lotDetails){
		this.lotInfoArray[this.count] = lotDetails;
		this.count++;
	  }

	  Week.prototype.getLotDetails = function(){

		return this.lotInfoArray;
	  }

	  function LotDetails(lotNumber, lotQty, date, status){
		this.lotNumber = lotNumber;
		this.lotQty = lotQty;
		this.date = date;
                this.status = status;
	  }

	  LotDetails.prototype.getLotNumber = function() {
		return this.lotNumber;
	  }

	  LotDetails.prototype.getLotQty = function(){
		return this.lotQty;
	  }

	  LotDetails.prototype.getDate = function(){
		return this.date;
	  }

          LotDetails.prototype.getStatus = function() {
                return this.status;
          }

	  function addWeeks(index, week){
		holdWeeks[index] = week;
		//holdCount++;
	  }

	  function getWeek(index){
		return holdWeeks[index];
	  }

	  function displayLotDetails(index, qty){

		//alert("This is check in displayLotDetails() ");

		if(qty == 0){
			return;
		}
                //alert("disPlayLotDetails Index = "+index);
		var week = getWeek(index);
                createDivision(week);
	  }

	  function closeLotDetails(){

		var d = window.document;
		var e = window.event;
		var style = d.all["lotDivision"].style;

		if(style.visibility == "visible"){
			style.visibility = "hidden";
		}
	  }

        //Added for scheduleOrderInfo
        function OrderWeek(name){
		this.count = 0;
		this.name = name;
		this.orderInfoArray = new Array();
	  }

	  OrderWeek.prototype.addOrderDetails = function(orderDetails){
		this.orderInfoArray[this.count] = orderDetails;
		this.count++;
	  }

	  OrderWeek.prototype.getOrderDetails = function(){
		return this.orderInfoArray;
	  }

	  function OrderDetails(salesOrderNo, lineItemNo, orderQuantity, scheduleDate, customerName){
		this.salesOrderNo = salesOrderNo;
                this.lineItemNo = lineItemNo;
                this.orderQuantity = orderQuantity;
                this.scheduleDate = scheduleDate;
                this.customerName = customerName;
	  }

	  OrderDetails.prototype.getSalesOrderNo = function() {
		return this.salesOrderNo;
	  }

	  OrderDetails.prototype.getLineItemNo = function(){
		return this.lineItemNo;
	  }

	  OrderDetails.prototype.getOrderQuantity = function(){
		return this.orderQuantity;
	  }

          OrderDetails.prototype.getScheduleDate = function() {
                return this.scheduleDate;
          }

          OrderDetails.prototype.getCustomerName = function() {
                return this.customerName;
          }

	  function addOrderWeeks(index, orderWeek){
        // modified by prabhanjan on 27th October 2003 as the array for lot details and sales orders separated.
		holdOrderWeeks[index] = orderWeek;
		//holdCount++;
	  }

	  function getOrderWeek(index){
        // modified by prabhanjan on 27th October 2003.
		return holdOrderWeeks[index];
	  }

	  function displayOrderDetails(index, qty){

		//alert("This is check in displayLotDetails() ");

		if(qty == 0){
			return;
		}

		var orderWeek = getOrderWeek(index);
		createOrderDivision(orderWeek);
	  }

	  function closeOrderDetails(){

		var d = window.document;
		var e = window.event;
		var style = d.all["orderDivision"].style;

		if(style.visibility == "visible"){
			style.visibility = "hidden";
		}
	  }


	  function init(){

		var d = window.document;
		//body = createHeading();
                d.writeln('<div ID="'+division+'" ');
		d.writeln(' style="Z-INDEX: 1; LEFT: 350px; VISIBILITY: hidden;');
		//d.writeln(' WIDTH: 146px; HEIGHT: 108px; POSITION: absolute;');
		d.writeln('POSITION:absolute;');
		d.writeln('TOP: 96px; BACKGROUND-COLOR:');
		d.write(divColor+';">');
		d.writeln(this.body);
		d.writeln('</div>');

                //Added for B/L Schedule Orders
                d.writeln('<div ID="'+division1+'" ');
		d.writeln(' style="Z-INDEX: 1; LEFT: 350px; VISIBILITY: hidden;');
		//d.writeln(' WIDTH: 146px; HEIGHT: 108px; POSITION: absolute;');
		d.writeln('POSITION:absolute;');
		d.writeln('TOP: 196px; BACKGROUND-COLOR:');
		d.write(divColor+';">');
		d.writeln(this.body);
		d.writeln('</div>');

	  }

	  function createDivision(week){

		this.body = createHeading();
		this.body += createBody(week);
		this.body += '</TABLE>';

		var d = window.document;
		var e = window.event;

		if(d.all["lotDivision"].style.visibility == "hidden"){
			d.all["lotDivision"].style.visibility = "visible";
		}
		d.all["lotDivision"].innerHTML = this.body;
	  }

	  function createHeading(){

		var body1 = '<TABLE ALIGN="center" VALIGN="middle" BORDER="1" ';
	 	body1 += 'CELLSPACING="0"  CELLPADDING="1" >';
		body1 += '<TR ALIGN="center" VALIGN="middle">';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Lot Number';
		body1 += '</FONT></TD>';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Quantity';
		body1 += '</FONT></TD>';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Date To FG';
		body1 += '</FONT></TD>';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Current Step';
		body1 += '</FONT></TD>';

		body1 += '</TR>';

		return body1;
	  }

	  function createBody(week){
                //alert('Week ' + week);
		var lot = week.getLotDetails();
                //alert("Lot = "+lot);
		var body1 = "";
		for(var k=0; k<lot.length; k++){
			body1 += '<TR ALIGN="center" VALIGN="middle">';
			body1 += '<TD ALIGN="center" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">'
			body1 += lot[k].getLotNumber();
			body1 += '</FONT></TD>';

			body1 += '<TD ALIGN="right" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">';
			body1 += lot[k].getLotQty();
			body1 += '&nbsp;&nbsp;</FONT></TD>';

			body1 += '<TD ALIGN="center" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">';
			body1 += lot[k].getDate();
			body1 += '</FONT></TD>';

                        body1 += '<TD ALIGN="center" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">';
			body1 += lot[k].getStatus();
			body1 += '</FONT></TD>';
			body1 += '</TR>';
		}

		return body1;
	  }

        function createOrderDivision(orderWeek){

		this.body = createOrderHeading();
		this.body += createOrderBody(orderWeek);
		this.body += '</TABLE>';

		var d = window.document;
		var e = window.event;

		if(d.all["orderDivision"].style.visibility == "hidden"){
			d.all["orderDivision"].style.visibility = "visible";
		}
		d.all["orderDivision"].innerHTML = this.body;
	  }

	  function createOrderHeading(){

		var body1 = '<TABLE ALIGN="center" VALIGN="middle" BORDER="1" ';
	 	body1 += 'CELLSPACING="0"  CELLPADDING="1" >';
		body1 += '<TR ALIGN="center" VALIGN="middle">';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Sales Order #';
		body1 += '</FONT></TD>';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Line Item #';
		body1 += '</FONT></TD>';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Customer Name';
		body1 += '</FONT></TD>';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Quantity';
		body1 += '</FONT></TD>';

		body1 += '<TD ALIGN="center" VALIGN="middle" bgcolor="';
		body1 += this.bgColor+'">';
		body1 += '<FONT class='+ styleSheet+'>';
		body1 += 'Schedule Date';
		body1 += '</FONT></TD>';

		body1 += '</TR>';

		return body1;
	  }

	  function createOrderBody(orderWeek){

		var order = orderWeek.getOrderDetails();
		var body1 = "";

		for(var k=0; k<order.length; k++){
			body1 += '<TR ALIGN="center" VALIGN="middle">';
			body1 += '<TD ALIGN="center" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">'
			body1 += order[k].getSalesOrderNo();
			body1 += '</FONT></TD>';

			body1 += '<TD ALIGN="right" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">';
			body1 += order[k].getLineItemNo();
			body1 += '&nbsp;&nbsp;</FONT></TD>';

                        body1 += '<TD ALIGN="left" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">';
			body1 += order[k].getCustomerName();
			body1 += '</FONT></TD>';

			body1 += '<TD ALIGN="center" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">';
			body1 += order[k].getOrderQuantity();
			body1 += '</FONT></TD>';

                        body1 += '<TD ALIGN="center" VALIGN="middle" >';
			body1 += '<FONT class="'+ fontColor+'">';
			body1 += order[k].getScheduleDate();
			body1 += '</FONT></TD>';
			body1 += '</TR>';
		}

		return body1;
	  }


      // Added by Prabhanjan on 16th November 2003
      // for refreshing order scheduling search screen if the schedule date is saved
      function closeWindow ()
      {
        if(isScheduleDateSaved == 1)
        {
            var openerDoc = window.opener.document;
                // Modified by Prabhanjan on 22 November 2003
                // for checking whethere this page is opened from order scheduling search screen or pending orders screen
                if(openerDoc.all.fromOrderScheduling.value != "false")
                {
                    openerDoc.scheduling.marketingPartNo.value = openerDoc.scheduling.prevMarketingPartNo.value;
                    openerDoc.scheduling.customerId.value = openerDoc.scheduling.prevCustomerId.value;
                    openerDoc.scheduling.salesOrderNo.value = openerDoc.scheduling.prevSalesOrderNo.value;
                    window.opener.searchOrderList(openerDoc.scheduling);
                }
              // Commented by Prabhanjan on 24 Nov 2003
              /*
                else
                {
                    window.opener.history.go(0);
                }
              */
        }

        window.close();
      }
      // till here Prabhanjan

	var week = "";
        var orderWeek = "";

<%
    HashMap lotQtyMap = (HashMap) request.getAttribute("lotDetails");
    if (lotQtyMap != null) {

        Iterator lotkeys = lotQtyMap.keySet().iterator();
        Iterator steps = null;
        HashMap stepQtyMap = null;
        String week = null;
        String psName = null;
        LotQuantity psLotQuantity = null;
        LotNumberQtyAndDateOut lotDetails = null;
        int qty = 0;
        int totalQty = 0;
	  int i = 0;
        while (lotkeys.hasNext()) {
        
            week = (String) lotkeys.next();
	      
%>

            week = new Week();
<%
            
            stepQtyMap = (HashMap) lotQtyMap.get (week);
            steps = stepQtyMap.keySet().iterator();
            
            while (steps.hasNext()) {
                psName = (String) steps.next();
                psLotQuantity = (LotQuantity) stepQtyMap.get (psName);
            
                Iterator lotsList = psLotQuantity.getLotNumberQtyList().iterator();
            
                while (lotsList.hasNext()) {                    
                    lotDetails = (LotNumberQtyAndDateOut)lotsList.next();
            
                    String lotNumber = lotDetails.getLotNumber();
                    int lotQty    = lotDetails.getQuantity();
                    java.util.Date lotDate   = lotDetails.getExpectedDateOut();
                    String lotStatus = lotDetails.getStatus();
%>
                    // commented by Prabhanjan on 31st October 2003 to display the current step of the lot instead of lot status.
                    // The next line after this commented code contains code to display psName(Process Step Name).
                    // week.addLotDetails(new LotDetails('<%=lotNumber%>','<%=StringUtils.formatUnits(lotQty)%>','<%=StringUtils.formatDateToString(lotDate)%>','<%=lotStatus%>'));
                    week.addLotDetails(new LotDetails('<%=lotNumber%>','<%=StringUtils.formatUnits(lotQty)%>','<%=StringUtils.formatDateToString(lotDate)%>','<%=psName%>'));

<%
                }                
            }    
%>

		addWeeks(<%= week%>, week);
<%
     
        }
    }

%>


<%        
    HashMap orderQtyMap = (HashMap) request.getAttribute("scheduleOrderDetails"); 
    if (orderQtyMap != null) {

        Iterator orderkeys = orderQtyMap.keySet().iterator();
        Iterator steps = null;        
        String orderWeek = null;        
        ReservedQuantity psReservedQuantity = null;
        LineItem lineItem = null;
        int qty = 0;
        int totalQty = 0;
	  int i = 0; 
        while (orderkeys.hasNext()) {
        
            orderWeek = (String) orderkeys.next();
	      //System.out.println("Order Week = " + orderWeek);
%>

            orderWeek = new OrderWeek();
<%
            
            psReservedQuantity = (ReservedQuantity) orderQtyMap.get (orderWeek);
            
            Iterator ordersList = psReservedQuantity.getLineItemQtyAndSchDateList().iterator();
            
            while (ordersList.hasNext()) {
                    lineItem = (LineItem)ordersList.next();
                    
                    String salesOrderNo = lineItem.getSalesOrderNo();
                    int lineItemNo = lineItem.getLineItemNo();
                    int orderQty = lineItem.getQuantity();
                    String scheduleDate = lineItem.getScheduleDate();
                    String customerName = lineItem.getCustomerName();
%>                    
                    orderWeek.addOrderDetails(new OrderDetails('<%=salesOrderNo%>','<%=lineItemNo%>','<%=StringUtils.formatUnits(orderQty)%>','<%=scheduleDate%>','<%=customerName%>'));
<%
            }    
%>

		addOrderWeeks(<%= orderWeek%>, orderWeek);  // modified by prabhanjan on 27th October 2003
<%
     
        }
    }

%>


//-->
</SCRIPT>
</HEAD>

<BODY bgcolor="ffffff" marginheight="0" marginwidth="0" topmargin=0 leftmargin=0 >
<script language="JavaScript1.2">
<!--
		init();
//-->
</script>
<table cellpadding="10" cellspacing="0" border="0" width="100%">
<tr bgcolor="#8C87A8"><td height="30" valign="top" align=center><font class="NArialL"><font color="#FFFFFF">Order Scheduling For Product ->> <%= request.getParameter("marketingPartNo")%></font><br>
</td><td valign="top" align="right">
<!--
Commented by Prabhanjan on 16th November 2003.
Added the code below to call the closeWindow() function, if the schedule date is saved, else close the window normally.
-->
<!-- <a href="javascript:window.close()"><font class="NArial">Close</font></a> -->
<logic:present name="isScheduleDateSaved"  >
   <logic:match name="isScheduleDateSaved" value="true" >
       <a href="javascript:closeWindow();"><font class="NArial">Close</font></a>
       <script>isScheduleDateSaved = 1;</script>
   </logic:match>
</logic:present>
<logic:notPresent name="isScheduleDateSaved"  >
   <a href="javascript:window.close()"><font class="NArial">Close</font></a>
</logic:notPresent>



</td></tr></table>

<% Calendar calDate = new GregorianCalendar();
   Date date11 = new Date();
   calDate.setTime(date11);   
   
   calDate.add(Calendar.DATE,6);
   Date date12 = calDate.getTime();
   String week1 = StringUtils.formatDateToString(date11,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date12,"MM/dd/yy");
   
   calDate.add(Calendar.DATE,1);
   Date date21 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date22 = calDate.getTime();
   String week2 = StringUtils.formatDateToString(date21,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date22,"MM/dd/yy");
   
   calDate.add(Calendar.DATE,1);
   Date date31 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date32 = calDate.getTime();
   String week3 = StringUtils.formatDateToString(date31,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date32,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date41 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date42 = calDate.getTime();
   String week4 = StringUtils.formatDateToString(date41,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date42,"MM/dd/yy");
   
   calDate.add(Calendar.DATE,1);
   Date date51 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date52 = calDate.getTime();
   String week5 = StringUtils.formatDateToString(date51,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date52,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date61 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date62 = calDate.getTime();
   String week6 = StringUtils.formatDateToString(date61,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date62,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date71 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date72 = calDate.getTime();
   String week7 = StringUtils.formatDateToString(date71,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date72,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date81 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date82 = calDate.getTime();
   String week8 = StringUtils.formatDateToString(date81,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date82,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date91 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date92 = calDate.getTime();
   String week9 = StringUtils.formatDateToString(date91,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date92,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date101 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date102 = calDate.getTime();
   String week10 = StringUtils.formatDateToString(date101,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date102,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date111 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date112 = calDate.getTime();
   String week11 = StringUtils.formatDateToString(date111,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date112,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date121 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date122 = calDate.getTime();
   String week12 = StringUtils.formatDateToString(date121,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date122,"MM/dd/yy");

   calDate.add(Calendar.DATE,1);
   Date date131 = calDate.getTime();
   calDate.add(Calendar.DATE,6);
   Date date132 = calDate.getTime();
   String week13 = StringUtils.formatDateToString(date131,"MM/dd/yy") + " to " +StringUtils.formatDateToString(date132,"MM/dd/yy");


%>
<table border="10" width="100%" bordercolor="#FFFFFF">
	<tr>
	  <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week1 %></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week2 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week3 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week4 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week5 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week6 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week7 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week8 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week9 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week10 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week11 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week12 %></font></font></td>
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><%=week13 %></font></font></td>
	</tr>
        <% int bgcount = 0;%>
	
        <% ArrayList list = (ArrayList) request.getAttribute("scheduleUnits"); 
           for(int i=0; i<list.size(); i++)
           {
                Inventory inventory = (Inventory) list.get(i);
                bgcount = bgcount + 1; 
             if(bgcount == 3) { %>
            <tr><td colspan=14 bgcolor="#000000"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=1></td></tr>
            <% } %>
            <% if(bgcount == 5) {%>
            <tr><td colspan=14 bgcolor="#FFFFEE"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='20'></td></tr>
            <% } %>
	<tr>
	  <td width="15%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
	  <%if(inventory.getProcessType().equalsIgnoreCase("Reserved Units"))
			   { %>
				 <bean:message key = "label.reservedUnits" /> 
			 <%  }
			 else%><%=inventory.getProcessType()%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(1, <%=inventory.getWeek1()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek1()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(1, <%=inventory.getWeek1()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek1()%></A><%}else{%><%= inventory.getWeek1()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(2, <%=inventory.getWeek2()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek2()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(2, <%=inventory.getWeek2()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek2()%></A><%}else{%><%= inventory.getWeek2()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(3, <%=inventory.getWeek3()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek3()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(3, <%=inventory.getWeek3()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek3()%></A><%}else{%><%= inventory.getWeek3()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(4, <%=inventory.getWeek4()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek4()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(4, <%=inventory.getWeek4()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek4()%></A><%}else{%><%= inventory.getWeek4()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(5, <%=inventory.getWeek5()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek5()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(5, <%=inventory.getWeek5()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek5()%></A><%}else{%><%= inventory.getWeek5()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(6, <%=inventory.getWeek6()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek6()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(6, <%=inventory.getWeek6()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek6()%></A><%}else{%><%= inventory.getWeek6()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(7, <%=inventory.getWeek7()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek7()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(7, <%=inventory.getWeek7()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek7()%></A><%}else{%><%= inventory.getWeek7()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(8, <%=inventory.getWeek8()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek8()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(8, <%=inventory.getWeek8()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek8()%></A><%}else{%><%= inventory.getWeek8()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(9, <%=inventory.getWeek9()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek9()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(9, <%=inventory.getWeek9()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek9()%></A><%}else{%><%= inventory.getWeek9()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(10, <%=inventory.getWeek10()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek10()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(10, <%=inventory.getWeek10()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek10()%></A><%}else{%><%= inventory.getWeek10()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(11, <%=inventory.getWeek11()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek11()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(11, <%=inventory.getWeek11()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek11()%></A><%}else{%><%= inventory.getWeek11()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(12, <%=inventory.getWeek12()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek12()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(12, <%=inventory.getWeek12()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek12()%></A><%}else{%><%= inventory.getWeek12()%><%}%></font></td>
	  <td width="6%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><% if(inventory.getProcessType().equalsIgnoreCase("Shippable Units")){%><A onmouseover='javascript:displayLotDetails(13, <%=inventory.getWeek13()%>)' onmouseout='javascript:closeLotDetails()'><%=inventory.getWeek13()%></A><%} else if(inventory.getProcessType().equalsIgnoreCase("B/L By sch. Date")){%><A onmouseover='javascript:displayOrderDetails(13, <%=inventory.getWeek13()%>)' onmouseout='javascript:closeOrderDetails()'><%=inventory.getWeek13()%></A><%}else{%><%= inventory.getWeek13()%><%}%></font></td>

	</tr>
        <% } %>
        
  </table>
<table border="0" width="100%" bordercolor="#FFFFFF">
	<tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td></tr>
</table>
<table border="0" width="100%" bordercolor="#FFFFFF">    
	<tr>
	  <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Current Inventory</font></td>	  
          <logic:iterate id="Inventory" name="inventroryDetails">
	  <td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">
                <bean:write name="Inventory" property="processType"/></font></font>
           </td>
          </logic:iterate>
	</tr>
	<tr>
	  <td width="15%" align="center" bgcolor="#DEE1E2"><font class="NArialL">Good Units</font></td>
          <logic:iterate id="Inventory" name="inventroryDetails">
	  <td width="6%" align="center" bgcolor="#DEE1E2"><font class="NArialL"><bean:write name="Inventory" property="goodUnits" /></font></td>	  
          </logic:iterate>
	</tr>
	<tr>
	  <td width="15%" align="center" bgcolor="#FFFFEE"><font class="NArialL">Hold Units</font></td>
          <logic:iterate id="Inventory" name="inventroryDetails">
	  <td width="6%" align="center" bgcolor="#FFFFEE"><font class="NArialL"><bean:write name="Inventory" property="holdUnits" /></font></td>	  
          </logic:iterate>
	</tr>

  </table>

<%

    LineItem lineItemFromSession = (LineItem) session.getAttribute ("lineItem");
    // Show Lot Reservation Matrix for this line item

    String lineItemNo = request.getParameter ("lineItemNo");
    String salesOrderId = request.getParameter ("salesOrderId");

    HashMap reservedLotQtyByWeekMap = null;
    if (lineItemFromSession != null) {
        reservedLotQtyByWeekMap = lineItemFromSession.getReservedLotQtyByWeekMap();
    }

    if (reservedLotQtyByWeekMap == null) {
        reservedLotQtyByWeekMap = SalesDAO.getReservedLotQuantityByLineItem (lineItemNo, salesOrderId);
    }

    if ((reservedLotQtyByWeekMap != null) && (reservedLotQtyByWeekMap.isEmpty() == false)) {
%>

<table border="0" width="100%" bordercolor="#FFFFFF">
	<tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td></tr>
        <tr><td><font class="NArialL"><font color="#000000">Quantity Reservation Matrix:</font></font></td></tr>
</table>


<table border="0" width="100%" bordercolor="#FFFFFF">    

<%

                ArrayList inventroryDetails = (ArrayList) request.getAttribute ("inventroryDetails");
                if (inventroryDetails != null) {

                    String processStepName = null;
                    Inventory inventory = null;
                    int inventroryDetailsSize = inventroryDetails.size();
%>
                    <tr><td width='15%' align='center' bgcolor='#993333'><font class="NArialL">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<%
                    for (int i=(inventroryDetailsSize-1); i>=0; i--) {
                        inventory = (Inventory) inventroryDetails.get (i);
                        processStepName = inventory.getProcessType();
%>
                        <td width="6%" align='center' bgcolor='#993333'><font class="NArialL"><font color="#FFFFFF"><%=processStepName%></font></font></td>
<%
                    }
%>
                    </tr>
<%
                    LotQuantity reservedLotQty = null;
                    HashMap reservedProcessStepLotQty = null;
                    ArrayList lotNumberQtyList = null;
                    Iterator keys = null;
                    LotNumberQtyAndDateOut key = null;
                    String bgColor = null;

                    for (int weekNumber=13; weekNumber>=1; weekNumber--) {
                        if (weekNumber%2 == 0) bgColor="#FFFFFF";
                        else bgColor="#DEE1E2";
%>
                    <tr><td width='15%' align='center' bgcolor='<%=bgColor%>'><font class="NArialL"><font color="#000000"><%="Week " + weekNumber%> </font></font></td>
<%
                        reservedProcessStepLotQty = (HashMap) reservedLotQtyByWeekMap.get (weekNumber+"");
                        
                        for (int i=(inventroryDetailsSize-1); i>=0; i--) {
                            inventory = (Inventory) inventroryDetails.get (i);
                            processStepName = inventory.getProcessType();
                            
                            if (reservedProcessStepLotQty == null) {
%>
                            <td width="6%" align='center' bgcolor='<%=bgColor%>'><font class="NArialL"><font color="#FFFFFF">&nbsp;</font></font></td>
<%
                            }
                            else {
                                reservedLotQty = (LotQuantity) reservedProcessStepLotQty.get (processStepName);
                                if (reservedLotQty != null) {
                                    lotNumberQtyList = reservedLotQty.getLotNumberQtyList();
                                    
                                    if (lotNumberQtyList != null) {
%>
                                <td width="6%" align='left' nowrap bgcolor='<%=bgColor%>'><font class="NArialL"><font color="#000000">
<%
                                        keys = lotNumberQtyList.iterator();
                                        while (keys.hasNext()) {
                                            key = (LotNumberQtyAndDateOut) keys.next();
                                            out.println (key.getLotNumber() + " -> " + key.getQuantity() + "<br>");
                                        }
%>
                                </font></font></td>
<%
                                    }
                                }
                                else {
%>
                                <td width="6%" align='center' bgcolor='<%=bgColor%>'><font class="NArialL"><font color="#FFFFFF">&nbsp;</font></font></td>
<%
                                }
                            }
                        }
%>
                    </tr>
<%
                    }
                }
%>
            </table>
<%
    }


    // SHOW THE LINE ITEM FOR THIS LINE_ITEM_NUMBER AND SALES_ORDER_ID
    LineItem lineItem = lineItemFromSession;
    if (lineItem == null) {
        lineItem = SalesOrderDAO.loadOrderLineItem (lineItemNo, salesOrderId);
    }

    if (lineItem != null) {
        String status = lineItem.getStatus();
%>
<!--Bhaskar added this scriptlet on 11 july 2003 -->
<% User users = (User) session.getAttribute (SessionKeys.USER_KEY); %>
<form name='lineItemForm' method='post'>

    <input type='hidden' name='lineItemNo' value='<%=lineItemNo%>'>
    <input type='hidden' name='salesOrderId' value='<%=salesOrderId%>'>
    <input type='hidden' name='requestedDate' value='<%=lineItem.getRequestDate()%>'>
    <input type='hidden' name='marketingPartNo' value='<%=lineItem.getMarketingPartNo()%>'>
    <input type='hidden' name='quantity' value='<%=lineItem.getQuantity()%>'>
    <!-- Added by rohan on August 27th for storing the line Item ID-->
    <input type='hidden' name='lineItemId' value='<%=lineItem.getLineItemId()%>'>

    <table border="0" width="80%" align='left'>

        <tr><td colspan='12'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=25></td></tr>
        <tr><td>&nbsp;</td><td colspan='11' align='left'><chiptrack:info styleClass="NAriaL"/></td></tr>
        <tr><td>&nbsp;</td><td colspan='11' align='left'><chiptrack:errors styleClass="NAriaL"/></td></tr>
        <tr><td colspan='12'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=2></td></tr>
		<!--Added by Sarada on 30th Oct 2003 to do validations for scheduleDate -->
		<tr><td colspan='12' align="left" class='NArialL'><FONT id="errors" color='FF0000'></FONT><br></TD></tr>

        <tr><td>&nbsp;</td><td colspan='11' align='left'><font class="NArialL">Line Item Details:</font></td></tr>

        <tr>
            <td width="7%" align="center"><font class="NArialL">&nbsp;</td>
            <td width="5%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sales Order #</font></td>
            <td width="5%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Line Item</font></td>
            <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key = "label.mfgPartNumber" /></font></td>
            <td width="12%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Quantity</font></td>
            <td width="12%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Unit Price</font></td>
            <td width="12%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Req. Dock Date</font></td>
            <td width="12%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sugg Ship Date</font></td>
            <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Schedule Date</font></td>
            <td colspan='3' width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Actions</font></td>
        </tr>

         <tr>
            <td width="7%" align="center"><font class="NArialL">&nbsp;</td>
            <td width="5%"  bgcolor="#DEE1E2" align=center nowrap><font class="NArialL"><%=lineItem.getSalesOrderNo()%></font></td>
            <td width="5%"  bgcolor="#DEE1E2" align=center nowrap><font class="NArialL"><%=lineItem.getLineItemNo()%></font></td>
            <td width="15%" bgcolor="#DEE1E2" align=center nowrap><font class="NArialL"><%=lineItem.getMarketingPartNo()%></font></td>
            <td width="12%" bgcolor="#DEE1E2" align=right  nowrap><font class="NArialL">&nbsp;&nbsp;&nbsp;<%=lineItem.getQuantity()%></font></td>

            <td width="12%" bgcolor="#DEE1E2" align=right  nowrap><font class="NArialL"><%=lineItem.getUnitPrice()%></font></td>
            <td width="12%" bgcolor="#DEE1E2" align=right  nowrap><font class="NArialL"><%=lineItem.getRequestDate()%></font></td>
            
            <td width="12%" bgcolor="#DEE1E2" align=right  nowrap>
            <font class="NArialL">
            <%
                String suggDate = lineItem.getSuggScheduleDate();
                if ((suggDate == null) || (suggDate.trim().length() == 0)) {
            %>
                <a href="javascript:submitForm('reschedule')">Schedule</a>&nbsp;&nbsp;
            <%} else {%>
            <%=suggDate%><input type='hidden' name='systemSuggDate' value='<%=suggDate%>'>
            <%}%>
            </font></td>

            
            <td width="10%" bgcolor="#DEE1E2" align=center nowrap><font class="NArialL">&nbsp;&nbsp;
            <input type=text name='scheduleDate' size='11' maxlength='10' align='left' value='<%=lineItem.getScheduleDate()%>' class='txfield'>
            <!-- Added by veeru on 31st March 2004 -->
            <a href="javascript:openCalendar(document.lineItemForm.scheduleDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
            <!-- End of added by veeru>
            <input type=hidden name='hiddenScheduleDate' value='<%=lineItem.getScheduleDate()%>'>
            </font></td>

            <td width="4%"  bgcolor="#DEE1E2" align=center nowrap><font class="NArialL">&nbsp;
            <!--Bhaskar commented this link on 11 July 2003 >
            <a href="javascript:submitForm('saveScheduleDate')">Save Schedule Date</a>&nbsp;</font></td-->
            <!--Bhaskar added this link on 11 july 2003 to facilitate the modify rights enabled user to modify this page.-->
            <chiptrack:restrictedLink functionality='<%=Functionality.ORDER_SCHEDULING%>' action='<%=User.USER_ACTION_MODIFY%>'styleClass="leftsection" href="javascript:submitForm('saveScheduleDate');" onmouseover="window.status='Click to save schedule date';return true" onmouseout="window.status='';return true">Save Schedule Date</chiptrack:restrictedLink>

            <td width="3%"  bgcolor="#DEE1E2" align=center nowrap><font class="NArialL">&nbsp;
            <!--Bhaskar commented this link on 11 July 2003 >
            <a href="javascript:submitForm('reschedule')">Re-Schedule</a>&nbsp;</font></td-->
            <!--Bhaskar added this link on 11 july 2003 to facilitate the modify rights enabled user to modify this page.-->
            <chiptrack:restrictedLink functionality='<%=Functionality.ORDER_SCHEDULING%>' action='<%=User.USER_ACTION_MODIFY%>'styleClass="leftsection" href="javascript:submitForm('reschedule');" onmouseover="window.status='Click to reschedule';return true" onmouseout="window.status='';return true">Re-Schedule</chiptrack:restrictedLink>
            <td width="3%"  bgcolor="#DEE1E2" align=center nowrap><font class="NArialL">&nbsp;
            <a href="javascript:submitForm('releaseLots')">Release Lots</a>&nbsp;</font></td>

        </tr>
        <% if( !users.isActionAllowed ( Functionality.ORDER_SCHEDULING, 
        User.USER_ACTION_MODIFY ) )
        { %>
            <tr><td colspan=7 align='left'>
            <font class='NArialS'>
            <font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b>
            </font></td></tr>
        <% } %>

        <tr><td colspan='12'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=25></td></tr>

        <tr><td colspan='12' align='center'>
            <font class='NArialL'>
            <!--
            Commented by Prabhanjan on 16th November 2003
            Added the below code to call the closeWindow() function, if the schedule date is saved, else close the window normally.
            -->
            <!-- <a href="javascript:window.close()">Close This Window</a> -->

            <logic:present name="isScheduleDateSaved"  >
                <logic:match name="isScheduleDateSaved" value="true" >
                    <a href="javascript:closeWindow();">Close This Window</a>
                    <input type=hidden name="isScheduleDateSaved" value="true">
                    <script>isScheduleDateSaved = 1;</script>
                </logic:match>
            </logic:present>
            <logic:notPresent name="isScheduleDateSaved"  >
                <a href="javascript:window.close()">Close This Window</a>
            </logic:notPresent>
            <!-- till here Prabhanjan -->
            </font>
        </td></tr>

        <tr><td colspan='12'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=25></td></tr>


        </table>
</form>

<%
    }
%>



</HEAD>
</BODY>
</HTML>

